%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% COMPUTE TOTAL DEMAND FOR DEFORESTATION AND PLOT THE CURVES
% ACTUAL MONITORING VS FINES AT PRE-2004 LEVELS

% "DEFORESTATION IN THE AMAZON:
% A UNIFIED FRAMEWORK FOR ESTIMATION AND POLICY ANALYSIS"

% by Eduardo Souza-Rodrigues

% This version: November 2018

% OBSERVATIONS: 
% Run this program after running "dem_def_reg.m" & "dem_def_compute_demand.m"

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% (A) COMPUTE TOTAL DEMAND FUNCTIONS

% Demand, Actual Monitoring
load Demand_farm_1cp;
load Demand_farm_2cp;
load Demand_farm_3cp;
load Demand_farm_4cp;
demand_def_cp = Demand_farm_1cp(:,3) + Demand_farm_2cp(:,3) + Demand_farm_3cp(:,3) + Demand_farm_4cp(:,3);

% Demand, Fines at Pre-2004 levels
load Demand_farm_1cp_fines;
load Demand_farm_2cp_fines;
load Demand_farm_3cp_fines;
load Demand_farm_4cp_fines;
demand_def_cp_fines = Demand_farm_1cp_fines(:,3) + Demand_farm_2cp_fines(:,3) + Demand_farm_3cp_fines(:,3) + Demand_farm_4cp_fines(:,3);

%% PLOT DEMAND CURVES

% Plot Demand Curves - Actual Monitoring vs Fines at Pre-2004 Levels
demand_def_mon_fig = figure;
plot(demand_def_cp/10^6,transfer_cp,'b',demand_def_cp_fines/10^6,transfer_cp,'r--')
xlabel('Agricultural Area (Million hectares)','fontsize',15)
ylabel('Taxes (US$/ha)','fontsize',15)
title('Demand for Deforestation - Monitoring Efforts','fontsize',16)
axis([-3 50 0 90])
h_legend=legend('Actual Monitoring','Fines at pre-2004 Levels');
set(h_legend,'FontSize',16);
saveas(demand_def_mon_fig,'DemDef-Fines.png')


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

